<?php
/**
 * 签到管理
 * @copyright (c) Seer All Rights Reserved
 */

require_once 'globals.php';

	$Student_Attendance_Model = new Student_Attendance_Model();
	$action = $_POST['action'];

	//检索条件保持管理
	$studentID = isset($_REQUEST['student_id_select']) ? $_REQUEST['student_id_select'] : '';
	$studentName = isset($_REQUEST['student_name']) ? $_REQUEST['student_name'] : '';
	$courseID = isset($_REQUEST['course_id_select']) ? $_REQUEST['course_id_select'] : '';
	$courseName = isset($_REQUEST['course_name']) ? $_REQUEST['course_name'] : '';
	$courseBatch = isset($_REQUEST['course_batch_select']) ? $_REQUEST['course_batch_select'] : '';
	$lessonNum = isset($_REQUEST['lesson_num_select']) ? $_REQUEST['lesson_num_select'] : '';
	$page = $_REQUEST['pid'] ? $_REQUEST['pid'] : '1';
	$addUrl = $studentID ? "student_id_select={$studentID}&" : '';
	$addUrl .= $studentName ? "student_name={$studentName}&" : '';
	$addUrl .= $courseID ? "course_id_select={$courseID}&" : '';
	$addUrl .= $courseName ? "course_name={$courseName}&" : '';
	$addUrl .= $courseBatch ? "course_batch_select={$courseBatch}&" : '';
	$addUrl .= $lessonNum ? "lesson_num_select={$lessonNum}&" : '';

//显示在线报名用户(用户一览表检索)
if ($action == '' ) {
	$pwd = '签到信息一览';

	$searchCondition=array(
		"student_id" =>$studentID,
		"course_id" =>$courseID,
		"course_batch" =>$courseBatch ,
		"lesson_num" =>$lessonNum ,
	);

	$attendanceNum = $Student_Attendance_Model->getAttendanceNum($searchCondition);
	$attendances = $Student_Attendance_Model->getAttendanceForAdmin( $page, $searchCondition);
	$pageurl =  pagination($attendanceNum, Option::get('admin_perpage_num'), $page, "attendance_list.php?{$addUrl}pid=");
	include View::getView('header');
	require_once View::getView('user/attendance_list');
	include View::getView('footer');View::output();
}
//显示在线报名用户(用户一览表检索)
if ($action == 'attendance' ) {
	$attendanceID = isset($_POST['attendanceID']) ? $_POST['attendanceID'] : '';
	$attendanceState = isset($_POST['state']) ? $_POST['state'] : '';
	$Student_Attendance_Model->attendanceStateUpdate($attendanceID,$attendanceState);
	seerDirect("attendance_list.php?{$addUrl}pid=$page");
}